﻿using JuCloudy.Data.Nhibernate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace JuSolution.Web.ApiService
{
    /// <summary>
    /// AuthenticationService 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    // [System.Web.Script.Services.ScriptService]
    public class AuthenticationService : System.Web.Services.WebService
    {
        private AuthenticationContainer container { get; set; }

       [WebMethod]
        public String Auth(int UserId, string Password)
        {
            container = new AuthenticationContainer();
            return container.Auth(UserId, Password).Serialize();
        }

        [WebMethod]
       public String AuthByUserName(string UserName, string Password)
        {
            container = new AuthenticationContainer();
            return container.AuthByUserName(UserName, Password).Serialize();
        }

        [WebMethod]
        public String Connect(string UserName)
        {
            container = new AuthenticationContainer();
            return container.Connect(UserName).Serialize();
        }

        [WebMethod]
        public void CreateNewUser(String UserInfo, string IpAddress)
        {
           container = new AuthenticationContainer();
           container.CreateNewUser(
               (JuCloudy.Data.Entity.SsoUserInfo)UserInfo.Deserialize(typeof(JuCloudy.Data.Entity.SsoUserInfo))
               , IpAddress);
        }

        [WebMethod]
        public String EmailExsit(string Email)
        {
            container = new AuthenticationContainer();
            return container.EmailExsit(Email).Serialize();
        }

        [WebMethod]
        public String GetMemberInfo(string MemberId)
        {
            container = new AuthenticationContainer();
            return container.GetMemberInfo(MemberId).Serialize();
        }

        [WebMethod]
        public String GetMemberInfoByUserName(string UserName)
        {
            container = new AuthenticationContainer();
            return container.GetMemberInfoByUserName(UserName).Serialize();
        }

        [WebMethod]
        public String GetUserInfo(int UserId)
        {
            container = new AuthenticationContainer();
            return container.GetUserInfo(UserId).Serialize();
        }

        [WebMethod]
        public String GetUserInfoByUserName(string UserName)
        {
           container = new AuthenticationContainer();
           return container.GetUserInfoByUserName(UserName).Serialize();
        }

        [WebMethod]
        public String Login(string UserName, string Password, string IpAddress, out String UserInfo)
        {
            container = new AuthenticationContainer();
            return container.Login(UserName, Password, IpAddress, out UserInfo).Serialize();
        }

        [WebMethod]
        public void ReSetPassword(string memberId)
        {
           container = new AuthenticationContainer();
           container.ReSetPassword(memberId);
        }

        [WebMethod]
        public void ReSetPasswordByUserId(int UserId)
        {
           container = new AuthenticationContainer();
           container.ReSetPasswordByUserId(UserId);
        }

        [WebMethod]
        public void SetPassword(string MemberId, string Password, string IpAddress)
        {
            container = new AuthenticationContainer();
            container.SetPassword(MemberId, Password, IpAddress);
        }

        [WebMethod]
        public void SetPasswordByUserId(int UserId, string Password, string IpAddress)
        {
            container = new AuthenticationContainer();
            container.SetPasswordByUserId(UserId, Password, IpAddress);
        }

        [WebMethod]
        public bool TelPhoneExsit(string TelPhone)
        {
           container = new AuthenticationContainer();
           return container.TelPhoneExsit(TelPhone);
        }

        [WebMethod]
        public bool UserNameExsit(string UserName)
        {
           container = new AuthenticationContainer();
           return container.UserNameExsit(UserName);
        }
    }
}
